var Home = document.getElementsByClassName("home_page1");
var displayDiv = document.getElementsByClassName("displays");

function changeImage() {
    resetStyle();
    displayDiv[0].style.zIndex = 11;
}

function changeImage1() {
    resetStyle();
    displayDiv[1].style.zIndex = 11;
}

function changeImage3() {
    resetStyle();
    displayDiv[2].style.zIndex = 11;
}

function changeImage4() {
    resetStyle();
    displayDiv[3].style.zIndex = 11;
}

function changeImage5() {
    resetStyle();
    displayDiv[4].style.zIndex = 11;


}


function resetStyle() {
    //重置所有的图片的zindex的值为1,所有的li背景重置
    for (var i = 0, len = displayDiv.length; i < len; i++) {
        displayDiv[i].style.zIndex = 1;
    }
}

window.onload = function () {
    var upDate_b = document.getElementsByClassName("upDate_b");
    var img = document.getElementsByClassName("d");
    var pa = document.getElementsByClassName("a");
    var pb = document.getElementsByClassName("b");
    var pc = document.getElementsByClassName("c");
    var upDate = document.getElementById("upDate");
    /**
     * 方法概述： 修改礼品信息
     */
    for (var i = 0, len = upDate_b.length; i < len; i++) {
        upDate_b[i].onclick = function () {
            for (var j = 0, lens = img.length; j < lens; j++) {
                if (this === upDate_b[j]) {
                    var imgUrl = img[j].src;
                    var id = pa[j].innerHTML;
                    var name = pb[j].innerHTML;
                    var price = pc[j].innerHTML;
                    var imgs = document.getElementById("img");
                    var giftId = document.getElementById("giftId");
                    imgs.src = imgUrl;
                    giftId.innerHTML = id;
                    upDate.giftName.value = name;
                    upDate.giftPrice.value = price;

                    upDate.style.display = "block";
                    var off = document.getElementById("off");

                    off.onclick = function () {
                        upDate.style.display = "none";
                    }
                    var up = document.getElementById("upDate_a");
                    up.onclick = function () {
                        upDate.style.display = "none";
                        var giftNewName = upDate.giftName.value;
                        var giftNewPrice = upDate.giftPrice.value;
                        var giftNewImgUrl = upDate.giftImgUrl.value;
                        var url = "/administrator?methodName=updateGift&giftImgUrl=" + imgUrl + "&" +
                            "giftId=" + id + "&giftName=" + giftNewName + "&giftPrice=" + giftNewPrice;
                        var ajax = new XMLHttpRequest();
                        ajax.open("post", url);
                        ajax.send(null);
                        ajax.onreadystatechange = function () {
                            if (ajax.readyState === 4) {
                                if (ajax.status === 200 || ajax.status === 304) {
                                    var a = ajax.response;
                                    alert(a);
                                    //更新页面
                                    // window.location.replace(window.location.href)
                                }
                            }
                        }
                    }
                }
            }

        }
    }



    var upDate_b = document.getElementsByClassName("upDate_b");
    var img = document.getElementsByClassName("d");
    var pa = document.getElementsByClassName("a");
    var pb = document.getElementsByClassName("b");
    var pc = document.getElementsByClassName("c");
    var upDate = document.getElementById("upDate01");
    /**
     * 方法概述： 修改礼品信息
     */
    for (var i = 0, len = upDate_b.length; i < len; i++) {
        upDate_b[i].onclick = function () {
            for (var j = 0, lens = img.length; j < lens; j++) {
                if (this === upDate_b[j]) {
                    var imgUrl = img[j].src;
                    var id = pa[j].innerHTML;
                    var name = pb[j].innerHTML;
                    var price = pc[j].innerHTML;
                    var imgs = document.getElementById("img");
                    var giftId = document.getElementById("giftId");
                    imgs.src = imgUrl;
                    giftId.innerHTML = id;
                    upDate.giftName.value = name;
                    upDate.giftPrice.value = price;

                    upDate.style.display = "block";
                    var off = document.getElementById("off");

                    off.onclick = function () {
                        upDate.style.display = "none";
                    }
                    var up = document.getElementById("upDate_a");
                    up.onclick = function () {
                        upDate.style.display = "none";
                        var giftNewName = upDate.giftName.value;
                        var giftNewPrice = upDate.giftPrice.value;
                        var giftNewImgUrl = upDate.giftImgUrl.value;
                        var url = "/administrator?methodName=updateGift&giftImgUrl=" + imgUrl + "&" +
                            "giftId=" + id + "&giftName=" + giftNewName + "&giftPrice=" + giftNewPrice;
                        var ajax = new XMLHttpRequest();
                        ajax.open("post", url);
                        ajax.send(null);
                        ajax.onreadystatechange = function () {
                            if (ajax.readyState === 4) {
                                if (ajax.status === 200 || ajax.status === 304) {
                                    var a = ajax.response;
                                    alert(a);
                                    //更新页面
                                    // window.location.replace(window.location.href)
                                }
                            }
                        }
                    }
                }
            }

        }
    }


    /**
     * 新增礼物信息
     */
    document.getElementById("xz").onclick=function () {
        document.getElementById("upDate01").style.display="block";
    }
    document.getElementById("off01").onclick=function () {
        document.getElementById("upDate01").style.display="none";
    }

    /**
     * 举报信息显示
     */
    document.getElementById("ckxx").onclick=function () {
        document.getElementById("jbxx").style.display="block";
    }
    document.getElementById("off02").onclick=function () {
        document.getElementById("jbxx").style.display="none";
    }

    /**
     * 方法概述： 根据Id筛选主播
     */


    // document.getElementById("but03").onclick=function () {
    //     var but03_context=document.getElementById("but03_context").value;
    //     alert(but03_context);
    //     var url = "/administrator?methodName=getAnchorUserId&number=" + but03_context ;
    //     var ajax = new XMLHttpRequest();
    //     ajax.open("post", url);
    //     ajax.send(null);
    //     ajax.onreadystatechange = function () {
    //         if (ajax.readyState === 4) {
    //             if (ajax.status === 200 || ajax.status === 304) {
    //                 var a = ajax.response;
    //
    //
    //                 //更新页面
    //                 // window.location.replace(window.location.href)
    //             }
    //         }
    //     }
    // }
    //




    var count01 =document.getElementById("count01");
    var count =document.getElementById("count");
    var count02 =document.getElementById("count02");
    var stateName = document.getElementsByClassName("stateName");
    var stateName01 = document.getElementsByClassName("stateName01");
    var a = 0;
    var a1=0;
    for (var i = 0; i <stateName.length; i++) {
        var name =stateName[i].innerHTML;
        if ("在线"===name){
            a++;
        }
        if (i===stateName.length-1){
            count01.innerHTML = a+" 人";
        }
    }
    for (var i = 0; i <stateName01.length; i++) {
        var name =stateName01[i].innerHTML;
        if ("在线"===name){
            a1++;
        }
        if (i===stateName01.length-1){
            count02.innerHTML = a1+" 人";
        }
    }
    count.innerHTML = a1+a+" 人";




    var anchoryc =document.getElementsByClassName("anchoryc");
    var off04 =document.getElementsByClassName("off04");
    document.getElementById("but03").onclick=function () {
        var id =document.getElementsByClassName("id");
        var but03_context=document.getElementById("but03_context").value;
        for (var i=0;i<id.length;i++){
            if (id[i].innerHTML==but03_context){
                anchoryc[i].style.display="block";
                off04[i].onclick=function () {
                   for (var j=0;j<off04.length;j++){
                       if (this==off04[j]){
                           anchoryc[j].style.display="none";
                       }
                   }
                }
            }
        }
    }



};

//
// var anchoryc =document.getElementsByClassName("anchoryc");
// var off04 =document.getElementsByClassName("off04");
// function open() {
//     alert("1111");
//     var anchoryc =document.getElementsByClassName("anchoryc");
//     var id =document.getElementsByClassName("id");
//     var but03_context=document.getElementById("but03_context").value;
//     for (var i=0;i<id.length;i++){
//         if (id[i]==but03_context){
//             anchoryc[i].style.display="block";
//         }
//     }
// }
//
//
//     function close() {
//         anchoryc[i].style.display="none";
//
// }
